package com.demo5;

/**
 * Created by Administrator on 2017/3/26.
 */

public class JiCheng7 {
    private String name;
    private int age;
    private String type;
    private int weight;


    public static void main(String[] args) {
        Animal4 animal1 = new Fish4();
        Animal4 animal2 = new Tiger4();
        Animal4 animal3 = new Fish4();
        animal1.age = 12;
        animal1.name = "dingding";
        animal1.type = "dog";
        animal1.weight = 12;
        animal2.age = 12;
        animal2.name = "dingding";
        animal2.type = "dog";
        animal2.weight = 12;
        animal3.age = 12;
        animal3.name = "dangdang";
        animal3.type = "dog";
        animal3.weight = 12;
        System.out.println(animal1.equals(animal2));
        System.out.println(animal1.equals(animal3));

    }

    public boolean equals(Object ob) {
        boolean bool = false;
        if (this == ob)
            bool = true;
        if (ob == null)
            bool = false;
        if (ob instanceof Animal4) {
            bool = ((Animal4) ob).age == this.age
                    && ((Animal4) ob).name == this.name
                    && ((Animal4) ob).type == this.type
                    && ((Animal4) ob).weight == this.weight;
        }
        return bool;
    }
}
